//
//  CouldRemoveData.m
//  TenThousand
//
//  Created by apple on 16/7/21.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "CouldRemoveData.h"
#import "CouldRemoveModel.h"
#import "RemoveingModel.h"
#import "RemovedModel.h"
#import "AcceptedModel.h"

@implementation CouldRemoveData

-(NSMutableArray *)dataArr{
    if (!_dataArr) {
        _dataArr = [NSMutableArray array];
    }
    return _dataArr;
}




- (void)getBorrowList:(NSString *)method WithPage:(NSInteger)page Index:(NSInteger)index{
    
    
    NSString *loginId = [[NSUserDefaults standardUserDefaults] objectForKey:@"LoginId"];
    NSString *Index = [NSString stringWithFormat:@"%ld",page];
    NSDictionary *dict = @{
                           @"PageIndex":Index,
                           @"LoginId":loginId
                           };
    [NetWorkManager requestWithType:HttpRequestTypePost withMethodName:method withParaments:dict withSuccessBlock:^(NSDictionary *object) {
            NSLog(@"%@",object);
        if (page == 1) {
            [self.dataArr removeAllObjects];
        }
        if (index == 0) {
            NSArray *arr = [object[@"Data"] firstObject][@"ItemList"];
            for (NSDictionary *dic in arr) {
                CouldRemoveModel *model = [[CouldRemoveModel alloc]initWithDictionary:dic];
                [self.dataArr addObject:model];
            }
        }else if (index == 1) {
            NSArray *arr = [object[@"Data"] firstObject][@"ItemList"];
            for (NSDictionary *dic in arr) {
                RemoveingModel *model = [[RemoveingModel alloc]initWithDictionary:dic];
                [self.dataArr addObject:model];
                NSLog(@"%@",self.dataArr);
            }
        }else if (index == 2) {
            NSArray *arr = [object[@"Data"] firstObject][@"ItemList"];
            for (NSDictionary *dic in arr) {
                RemovedModel *model = [[RemovedModel alloc]initWithDictionary:dic];
                [self.dataArr addObject:model];
                NSLog(@"%@",self.dataArr);
            }
        }else {
            NSArray *arr = [object[@"Data"] firstObject][@"ItemList"];
            for (NSDictionary *dic in arr) {
                AcceptedModel *model = [[AcceptedModel alloc]initWithDictionary:dic];
                [self.dataArr addObject:model];
                NSLog(@"%@",self.dataArr);
            }
        }
        
        if (self.passDataBlock) {
            self.passDataBlock(self.dataArr);
        }
        
//            [self.myInvestTableView reloadData];
        
    } withFailureBlock:^(NSError *error) {
        NSLog(@"%@", error);
    } progress:^(float progress) {
        
    }];

    
    
    //return self.dataArr;
}


@end
